<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript">

        function validate_required(field,alerttxt)
        {
            with (field)
            {
                if (value==null||value=="")
                {alert(alerttxt);
                return false}
                else {return true}
            }
        }

        function validate_form(thisform)
        {
            with (thisform)
            {
                if (validate_required(email,"Email must be filled out!")==false)
                {email.focus();return false}
            }
        }
        //验证Email不能为空
        if (document.getElementById("Email").value==""||document.getElementById("Email").value==NaN){
            alert("Email不能为空");
            return false;
        }
        //验证Email格式不能为空
        var email =/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
        if (!document.getElementById("Email").value.match(email)){
            alert("Email格式错误");
            //重新获取焦点
            document.getElementById("Email").onfocus();
            return false;
        }
    </script>
</head>

<body>
<form action="submitpage.htm" onsubmit="return validate_form(this)" method="post">
    Email: <input type="text" name="email" size="30">
    <input type="submit" value="Submit">
</form>
</body>

</html>